<template>
  <div class="detail_page_content">
    <top-nav :title="routeParam.goodsName"></top-nav>
    <div>{{}}</div>
    <div class="detail_body">
      <div class="img_list">
<!--        <img
          v-for="(file, index) in goodsInfo.files"
          :key="index"
          :src="`${fileServer}${file.filePath}`"
        />-->
        <div v-for="(file, index) in goodsInfo.files" :key="index">
          <img v-if="file.type===1" :src="`${fileServer}${file.filePath}`" alt="Image" />
          <video v-else-if="file.type===2" :src="`${fileServer}${file.filePath}`" controls style="width:100%;" />
        </div>
      </div>
      <div class="goods_info">
        <div class="price_title">价格</div>
        <div class="sub_title">
          <span
            v-for="(price, index) in goodsInfo.prices"
            :key="index"
            >{{ price.detail }}</span
          >
        </div>
      </div>
      <div class="goods_info">
        <div class="price_title">特色</div>
        <ul class="tag_list">
          <li
            v-for="(label, index) in goodsInfo.labels"
            :key="index"
            class="tag_item"
          >
            {{ label.labelName }}
          </li>
        </ul>
        <div class="other_info">{{ goodsInfo.detail }}</div>
      </div>
    </div>
    <div class="bottom_button">
      <div class="goods_info">{{ goodsInfo.subGoodsName }}</div>
      <van-button type="primary" class="select_button" @click="onSelect(goodsInfo.belongs)"
        >联系一下</van-button
      >
    </div>
  </div>
</template>
<script setup>
import TopNav from "@/components/TopNav.vue";
import { ref, onMounted } from "vue";
import {useRoute, useRouter} from "vue-router";
import {
  fileServer,toPath
} from "@/network/api.js";
const routeParam = JSON.parse(useRoute().query.goodsParam);

const goodsInfo = ref({
  goodsName: routeParam.goodsName,
  subGoodsName: routeParam.subGoodsName,
  files: routeParam.fbFiles,
  prices: routeParam.prices,
  labels: routeParam.labels,
  detail: routeParam.detail,
  belongs: routeParam.belongs,
});

onMounted(() => {
  init();
});

function getImageUrl(name) {
  return new URL(`/src/assets/home/${name}.jpg`, import.meta.url).href;
}

const init = () => {

};

const onSelect = (toUser) => {
  window.location.href = toPath + toUser;
};
</script>

<style lang="scss" scoped>
.detail_page_content {
  width: calc(100% - 24px);
  position: relative;
  padding: 70px 12px 56px;
  .detail_body {
    .img_list {
      img {
        width: 100%;
        object-fit: cover;
      }
    }
    .goods_info {
      margin-bottom: 20px;
      .price_title {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 16px;
      }
      .sub_title {
        margin-top: 14px;
        font-size: 14px;
        & span {
          display: inline-block;
          margin-right: 60px;
          margin-bottom: 10px;
          white-space: nowrap;
        }
      }
      .tag_list {
        width: calc(100% - 20px);
        padding: 8px 10px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        row-gap: 10px;
        .tag_item {
          width: 26%;
          font-size: 12px;
          display: inline-block;
          border-radius: 12px;
          border: 1px solid #c8c8c8;
          background: #ffffff;
          padding: 2px 4px;
          text-align: center;
          color: #464a4b;
        }
      }
      .other_info {
        font-size: 12px;
        color: #464a4b;
      }
    }
  }

  .bottom_button {
    position: fixed;
    bottom: 10px;
    width: calc(100% - 24px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    .goods_info {
      display: inline-block;
      height: 46px;
      border-radius: 46px;
      width: 162px;
      border: 1px solid #c8c8c8;
      background: #ffffff;
      color: #3e3f48;
      font-size: 14px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .select_button {
      border-radius: 46px;
      width: 162px;
    }
  }
}
</style>
